import { type Dayjs } from 'dayjs';

export interface SearchInfo {
  rootCode?: string;
  code?: string;
}

export interface pageInfo {
  current?: number;
  pageSize?: number;
  total?: number;
  showTotal: Function;
  showSizeChanger: boolean;
  pageSizeOptions: string[];
  showSizeChange: Function;
  size: string;
  showQuickJumper: boolean;
  defaultPageSize: number;
}

export let pagination = ref<any>({
  // 数据总数
  total: 0,
  // 当前页数
  current: 1,
  // 每页条数
  pageSize: 10,
  // 展示总数
  showTotal: (total: number) => `共 ${total} 条`,
  // 是否可以改变pageSize
  showSizeChanger: true,
  // 设置每页可以展示多少条的选项
  pageSizeOptions: ['10', '20', '50', '100'],
  // 改变pageSize后触发
  showSizeChange: (current: number, pageSize: any) => (
    (pagination.value.current = current), (pagination.value.pageSize = pageSize)
  ),
  // 小尺寸分页
  size: 'small',
  // 是否可以快速跳转至某页
  showQuickJumper: true,
  //默认条数
  defaultPageSize: 10,
});

export const columns = ref<any>([
  {
    title: '邀请人编码',
    dataIndex: 'rootCode',
    key: 'rootCode',
  },
  {
    title: '邀请人名称',
    dataIndex: 'inviteCardName',
    key: 'inviteCardName',
  },
  {
    title: '层级',
    dataIndex: 'levelName',
    key: 'levelName',
  },
  {
    title: '被邀请人编码',
    dataIndex: 'code',
    key: 'code',
  },
  {
    title: '被邀请人名称',
    dataIndex: 'cardName',
    key: 'cardName',
  },
  {
    title: '被邀请人总消费',
    dataIndex: 'sumAmount',
    key: 'sumAmount',
  },
  {
    title: '分佣',
    dataIndex: 'totalCommission',
    key: 'totalCommission',
  },
]);


export interface DataItem {
  username: string;
  password: string;
  phone: string;
  code: string;
  status: string;
  wechatOpenid: string;
  wechatUnionid: string;
  avatar: number;
  self: number;
  wechatBindTime?: Dayjs | string;
  introUserId: number;
  codeNum: number;
  source: number;
}

export interface ModelInfo {
  title?: string;
  width?: string;
  id?: number | undefined;
  confirmLoading?: boolean;
}

export interface dictInfo {
  typeCode?: string | number | undefined,
  typeName?: string | undefined,
}

export const getSourceName = (source: number) => {
  switch (source) {
    case 1:
      return '官方来源';
    case 2:
      return '红娘';
    case 3:
      return '婚介所';
    default:
      return '未知';
  }
}